<?php
	include("modules/tblfile/fileclass.php");
	$obj = new File();
	$txtsearch = $_GET['txtsearch'];
	$dk ="";
	if($txtsearch != '')
	{
		$dk.=" WHERE FileName like '%".$txtsearch."%' ";
	}
	$dk .= " ORDER BY `tblfile`.`FileName` ASC";
	$data = $obj->getTable($dk);
	 /*******Start Paging*****************************/
	$page = $_GET['page'];			
	$limit = 20; 
	$total = count($data); 
	// work out the pager values 
	$pager  = Pager::getPagerData($total, $limit, $page); 
	$offset = $pager->offset; 
	$limit  = $pager->limit; 
	$page   = $pager->page;
	//$dk .= " LIMIT $offset , $limit";
	$data = $obj->getTable($dk);
?>
<script language="javascript" src="scripts/jquery.1.3.min.js"></script>
<style>
.grid{
	float:left;
	width:200px;
	height:150px;
}
</style>
Search: <input type="text" id="txtsearch" name="txtsearch" value="<?php echo $_GET['txtsearch']?>" /> <input type="button" name="btnSearch" value="Search" onclick="window.location='load.php?path=tblfile/file&txtsearch='+$('#txtsearch').val()"/>
<input type="hidden" id="selectfile" name="selectfile" value="" />
<div>
<input type="button" name="btnSelect" value="Select" onclick="selectFile()"/> <input type="button" name="btnCancel" value="Cancel"  onclick="cancel()"/>
</div>
<div>
	
    <?php foreach($data as $item){ ?>
   		<?php if(file_exists(DIR_FILE.$item['FilePath'])){ ?>
    <table class="grid">
        <tr>
            <td>
            	<center>
                    <img src="<?php echo $img->resizePNG($item['FilePath'],100,100)?>" /><br />
                    <input type="radio" name="chonfile"  value="<?php echo $item['FileID']?>" onchange="$('#selectfile').val(this.value)"/><br />
                    <?php echo $item['FileName']?><br />
                </center>
            </td>
            
        </tr>
    </table>
    	<?php }?>
    <?php }?>
<div>
<div style="float:none"></div>

<?php
	//include("modules/page.php");
?>

<script language="javascript">
function selectFile()
{
	window.opener.document.getElementById('selectfile').value = $("#selectfile").val();
	window.close();
}
function cancel()
{
	window.opener.document.getElementById('selectfile').value = "";
	window.close();
}
</script>